<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>菜单页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <th:block th:include="include :: header('菜单页面')" />
    <style type="text/css">
        .btn-sm {
            margin: 0 5px;
        }
    </style>
</head>
<body>

<div class="btn-group-sm" id="toolbar" role="group">
    <a class="btn btn-success" onclick="$.operate.add(0)" >
        <i class="fa fa-plus"></i> 新增
    </a>
    <a class="btn btn-primary" onclick="$.operate.edit()"  >
        <i class="fa fa-edit"></i> 修改
    </a>
    <a class="btn btn-info" id="expandAllBtn">
        <i class="fa fa-exchange"></i> 展开/折叠
    </a>
</div>
<div class="col-sm-12 select-table table-striped">
    <table id="bootstrap-tree-table"></table>
</div>

</body>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = "/system/menu";
    $(function() {
        var options = {
            code: "id",
            parentCode: "parentId",
            uniqueId: "id",
            expandAll: false,
            expandFirst: false,
            url: prefix + "/selectMenus",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "菜单",
            columns: [{
                field: 'selectItem',
                radio: true
            },
                {
                    title: '菜单名称',
                    field: 'menuTitle',
                    width: '20',
                    widthUnit: '%',
                    formatter: function(value, row, index) {
                        if ($.common.isEmpty(row.icon)) {
                            return row.menuTitle;
                        } else {
                            return '<i class="' + row.icon + '"></i> <span class="nav-label">' + row.menuTitle + '</span>';
                        }
                    }
                },
                {
                    field: 'sortIndex',
                    title: '排序',
                    width: '10',
                    widthUnit: '%',
                    align: "left"
                },
                {
                    field: 'menuUrl',
                    title: '请求地址',
                    width: '15',
                    widthUnit: '%',
                    align: "left",
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '类型',
                    field: 'type',
                    width: '10',
                    widthUnit: '%',
                    align: "left",
                    formatter: function(value, item, index) {
                        if (item.type == '1') {
                            return '<span class="label label-success">目录</span>';
                        }
                        else if (item.type == '2') {
                            return '<span class="label label-primary">菜单</span>';
                        }
                        else if (item.type == '3') {
                            return '<span class="label label-warning">按钮</span>';
                        }
                    }
                },
                {
                    field: 'status',
                    title: '可见',
                    width: '10',
                    widthUnit: '%',
                    align: "left",
                    formatter: function(value, row, index) {
                        if (row.status == 'F') {
                            return '-';
                        }
                        return 'mn'
                        // return $.table.selectDictLabel(datas, row.visible);
                    }
                },
                {
                    field: 'permission',
                    title: '权限标识',
                    width: '15',
                    widthUnit: '%',
                    align: "left",
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    width: '20',
                    widthUnit: '%',
                    align: "left",
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="$.operate.add(\'' + row.id + '\')"><i class="fa fa-plus"></i>新增</a> ');
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.treeTable.init(options);
    });

</script>
</html>